<template>
    <div class="goodsNum">
        <p v-show="food.count>0" @click="setCountJian( food )">-</p>
        <p v-show="food.count>0">{{food.count}}</p>
        <p @click=" setCountJa( food ) ">+</p>
    </div>
</template>

<script>
export default {
    props:['food'],
    data(){
        return {};
    },
    mounted(){
        // console.log(this.food);

    },
    methods: {
        setCountJa( obj ){
            if( obj.count === undefined ){
                obj.count = 1 ;
            }else{
                obj.count++;
            }
        },
        setCountJian( obj ){
            if( obj.count <= 0 ){
                obj.count = 0 ;
            }else{
                obj.count--;
            }
        }
    }
}
</script>

<style scoped>
.goodsNum {
    width: 24vw;
    height: 10vw;
    /* background-color: yellow; */
    position: absolute;
    top: 0vw;
    right: 0vw;
    display: flex;
}

.goodsNum>p {
    box-sizing: border-box;
}

.goodsNum>p:not(:nth-child(2)) {
    width: 7vw;
    height: 7vw;
    border: 0.533vw solid rgb(0, 160, 220);
    border-radius: 50%;
    font-size: 6vw;
    line-height: 4.8vw;
    text-align: center;
}

.goodsNum>p:first-child {
    color: rgb(0, 160, 220);
    background-color: white;
}

.goodsNum>p:nth-child(2) {
    width: 10vw;
    font-size: 3.2vw;
    line-height: 6.4vw;
    text-align: center;
    font-weight: 200;
}

.goodsNum>p:last-child {
    color: white;
    background-color: rgb(0, 160, 220);
    position: absolute;
    right: 0vw;
}

</style>